<template>
    <div>
        <div>
            <el-input class="searchInput" 
                    clearable
					@clear="keywordClear"
                    v-model="keyword"
                    placeholder="请输入公司关键字进行搜索..."
                    @keydown.enter.native="doSearch"
                    prefix-icon="el-icon-search">
            </el-input>
            <el-button icon="el-icon-search" type="primary" @click="doSearch">搜索</el-button> 
        </div>
        <div class="baseMain">
            <el-table
                    :data="bases"
                    border
                    stripe
                    style="width:93%">
                <el-table-column
                    prop="id" label="编号" width="55">
                </el-table-column>
                <el-table-column
                    prop="bname" label="公司名字" width="260">
                </el-table-column>
                <el-table-column
                    prop="dname" label="所属学院" width="140">
                </el-table-column>
                <el-table-column
                    prop="city" label="所在城市" width="80">
                </el-table-column>
                <el-table-column
                    prop="location" label="公司地址" width="400">
                </el-table-column>
                <el-table-column
                    prop="phone" label="联系电话" width="130">
                </el-table-column>
                <el-table-column
                    prop="startTime" label="合作起始时间">
                </el-table-column>
            </el-table>
        </div>
		<div class="pageSelect">
			<el-pagination
				  @current-change="handleCurrentChange"
				  :current-page="current"
				  :page-size="size"
				  layout="total, prev, pager, next, jumper"
				  :total="total">
			</el-pagination>
		</div>
    </div>
</template>

<script>
    export default {
        data () {
            return {
                bases:[],
                keyword:'',
				current: 1,
				size: 10,
				total: 0,
                
            }
        },
		mounted() {
			this.initBases();
		},
        methods: {
			initBases(){
				let url = '/information/base/?current=' + this.current + '&size=' + this.size + '&keyword=' + this.keyword;
				this.getRequest(url).then(resp =>{
					if(resp){
						this.bases = resp.data;
						this.total = resp.total;
					}
				})
			},
			keywordClear(){
				this.current = 1;
				this.initBases();
			},
            doSearch(){
				this.current = 1;
                this.initBases();
            },
			handleCurrentChange(currentPage){
				this.current = currentPage;
				this.initBases();
			}
        }
    }
</script>

<style scoped>
    .searchInput{
        width: 300px;
        margin-right: 8px;
    }
    .baseMain{
        margin-top: 10px;
    }
	.pageSelect{
		width: 85%;
		margin-top: 5px;
		display: flex;
		justify-content: flex-end;
	}
</style>